<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
    /**
    * initialize your data structure here.
    */
    var MinStack = function() {
        this.stack=[];
        this.min=[];
    };
    /** 
    * @param {number} x
    * @return {void}
    */
    MinStack.prototype.push = function(x) {
        this.stack.push(x);
        if(this.min.length==0||this.min[this.min.length-1]>=x)
        {
            this.min.push(x);
        }
    };

    /**
    * @return {void}
    */
    MinStack.prototype.pop = function() {
        var x=this.stack.pop();
        if(this.min[this.min.length-1]==x)
        {
            this.min.pop();
        }
    };

    /**
    * @return {number}
    */
    MinStack.prototype.top = function() {
        return this.stack[this.stack.length-1];
    };

    /**
    * @return {number}
    */
    MinStack.prototype.getMin = function() {
        return this.min[this.min.length-1];
    };

    /**
    * Your MinStack object will be instantiated and called as such:
    * var obj = new MinStack()
    * obj.push(x)
    * obj.pop()
    * var param_3 = obj.top()
    * var param_4 = obj.getMin()
    */
    </script>
</body>
</html>